import dayjs from "dayjs";
import req from "/@/api/req";
import { ID } from "/@/api/models";

export enum Api {
  articles = "articles",
  labels = "labels",
  specialColumns = "special-columns",
  members = "hand-picked-member",
  activity = "activity",
  allSpecialColumns = "special-columns/all",
  allLabels = "labels/all",
}

export interface Article {
  author?: string;
  content?: string;
  id?: ID;
  labelIds?: string | ID[];
  memberVisibleContent?: string;
  name?: string;
  pictureList?: string;
  specialColumnIds?: string | ID[];
  status?: number;
  theTop?: number;
  viewPermissions?: string;
}

export interface Label {
  createTime?: string;
  id?: ID;
  labelName: string;
  labelWeight: number;
  status?: number;
}

export interface SpecialColumn {
  createTime?: string;
  id?: ID;
  specialColumnName: string;
  specialColumnWeight: number;
  status?: number;
  icon?: string;
}

export interface SelectedMember {
  id?: ID;
  handPickedName: string;
  handPickedUrl: string;
  status?: number;
  weight?: number;
  userIds?: string[];
  checked?: boolean;
}

export interface SignUpItem {
  id: string;
  required: number | boolean;
  signUpField: string;
  signUpType: number;
  sort: number;
}

export interface Activity {
  activityName: string;
  activityUrl: string;
  activityWeight: number;
  id?: ID;
  registrationDeadline?: string | dayjs.Dayjs;
  status?: number;
  allowInvitees?: number;
  signUpList?: string | SignUpItem[];
}

export function getAllSpecialColumns() {
  return req.get<SpecialColumn[]>(
    {
      url: Api.allSpecialColumns,
    },
    {
      useGlobalLoading: false,
    }
  );
}

export function getAllLabels() {
  return req.get<Label[]>(
    {
      url: Api.allLabels,
    },
    {
      useGlobalLoading: false,
    }
  );
}
